package com.xja.warehouse.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.xja.warehouse.entity.ProviderEntity;
import com.xja.warehouse.service.ProviderService;
import com.xja.common.utils.PageUtils;
import com.xja.common.utils.R;

import javax.validation.Valid;


/**
 * 
 *
 * @author 共月
 * @email 1106739528@qq.com
 * @date 2023-11-25 23:09:46
 */
@RestController
@RequestMapping("warehouse/provider")
public class ProviderController {
    @Autowired
    private ProviderService providerService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    // @RequiresPermissions("warehouse:provider:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = providerService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    // @RequiresPermissions("warehouse:provider:info")
    public R info(@PathVariable("id") Integer id){
		ProviderEntity provider = providerService.getById(id);

        return R.ok().put("provider", provider);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    // @RequiresPermissions("warehouse:provider:save")
    public R save(@Valid @RequestBody ProviderEntity provider){
		providerService.save(provider);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    // @RequiresPermissions("warehouse:provider:update")
    public R update(@RequestBody ProviderEntity provider){
		providerService.updateById(provider);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    // @RequiresPermissions("warehouse:provider:delete")
    public R delete(@RequestBody Integer[] ids){
		providerService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
